<template>
	<w-container class="page-bg plr-16">
		<w-navbar id="my-nav" title="流转记录"></w-navbar>
		<view class="item bg-color-item br-12 mb-12" v-for="(item,idx) in list" :key="idx">
			<view class="left">
				<text class="font-size-14 font-color-textPrimary font-w-500"> {{ item.nickname }} </text>
				<text class="font-size-12 font-color-999 mt-8"> {{ $u.timeFormat(item.createtime, 'yyyy-mm-dd hh:MM:ss') }} </text>
			</view>
			<view class="right font-color-textPrimary">{{ source(item)&& handleLang(source(item)) }}</view>
		</view>
		<!-- 加载 -->
		<w-loading :type="loadingType" emptyType="search" class="mt-12" emptyTop="100"></w-loading>
	</w-container>
</template>

<script>
	import { flowDoc } from '@/api/user/index.js';
	export default {
		data() {
			return {
				id:'',
				page:1,
				loadingType:'none',
				isNext:true,
				list:[],
			};
		},
		onLoad({ id }) {
			this.id = id;
			this.refresh();
		},
		methods:{
			// 刷新
			refresh() {
				this.loadingType = 'none';
				this.isNext = true;
				this.list = [];
				this.page = 1;
				this.getList() 
			},
			
			// 获取列表
			getList() {
				if(!this.isNext) return;
				this.loadingType = 'loading';
				flowDoc({ uc_id:this.id,page:this.page }).then(res=>{
					uni.stopPullDownRefresh()
					let { data,last_page } = res.data;
					this.list = [...this.list,...data];
					if(this.page<last_page){
						this.page++;
					}else{
						this.isNext = false;
						this.loadingType = 'nomore';
					}
					!data.length && (this.loadingType = 'empty');
				}).catch(()=>{ this.loadingType = 'empty' })
			},
		
			// 来源
			source(item) {
				let { source_type,from_price } = item;
				switch(true) {
					case source_type==1:
						return `转入`
						break;
					case source_type==2:
						return `转入`
						break;
					case source_type==3:
						return `转入`
						break;
					case source_type==4:
						return `转入`
						break;
					case source_type==5:
						return `转入`
						break;
					case source_type==6:
						return `转入`
						break;
				}
			},
			
			onPullDownRefresh() {
				this.refresh()
			},
			
			onReachBottom() {
				this.getList();
			}
		}
	}
</script>

<style lang="scss">
	.item{
		width: 100%;
		height: 140rpx;
		padding: 0 48rpx 0 64rpx;
		@extend .flex-center-sb;
		
		>.left{
			@extend .flex,.flex-dir-col;
		}
		>.right{
			@extend .font-size-14; 
		}
		
	}
</style>
